package com.netease.nie.base.utils;

/**
 * 
 * @author KingsHunter
 * @createDate July 13th,2016
 * 
 */
public final class HashUtils {

	/**
	 * BKDR Hash method
	 * @param str
	 * @return
	 */
	public static int bkdrHash(String str) {
		int seed = 131; // 31 131 1313 13131 131313 etc..
		int hash = 0;

		for (int i = 0; i < str.length(); i++) {
			hash = (hash * seed) + str.charAt(i);
		}

		return (hash & 0x7FFFFFFF);
	}
}
